package com.cjyd.hrjb.config.mp;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.Instant;

/**
 * Created fei wo by 2020/4/5
 */
@Component
public class AutoFillFieldHandle implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        setFieldValByName("createdAt", Instant.now(), metaObject);
        setFieldValByName("updatedAt", Instant.now(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        setFieldValByName("updatedAt", Instant.now(), metaObject);
    }
}
